package com.gzhryc.common.data.dto;

import java.util.ArrayList;
import java.util.List;

/**
 * selecte2下拉框数据结构
 * @author 张浩
 * @version 2016-11-21
 */
public class SelectResult extends BaseResponse<SelectResult.Body>{
	
	private static final long serialVersionUID = 3153904848562129794L;
	
	public SelectResult(Integer code) {
		this.code = code;
		this.body = new SelectResult.Body();
	}

	public SelectResult(Integer code, String msg) {
		this.code = code;
		this.body = new SelectResult.Body();
	}

	public static class Body {
		
		protected Integer page = 1;
		protected Integer limit = 20;
		protected Long total;
		protected List<Item> data;
		
		public Body() {
			this.data = new ArrayList<Item>();
		}
		
		public Integer getPage() {
			return page;
		}
		public void setPage(Integer page) {
			this.page = page;
		}
		public Integer getLimit() {
			return limit;
		}
		public void setLimit(Integer limit) {
			this.limit = limit;
		}
		public Long getTotal() {
			return total;
		}
		public void setTotal(Long total) {
			this.total = total;
		}
		public List<Item> getData() {
			return data;
		}
		public void setData(List<Item> data) {
			this.data = data;
		}
		public Boolean getMore() {
			if(total != null && total > 0) {
				return total > page * limit;
			}
			return false;
		}
	}

	public static class Item {
		
		protected String id;
		protected String text;
		protected List<Item> children;
		protected Object data;			//附加信息
		
		public String getId() {
			return id;
		}
		public void setId(String id) {
			this.id = id;
		}
		public String getText() {
			return text;
		}
		public void setText(String text) {
			this.text = text;
		}
		public List<Item> getChildren() {
			return children;
		}
		public void setChildren(List<Item> children) {
			this.children = children;
		}
		public Object getData() {
			return data;
		}
		public void setData(Object data) {
			this.data = data;
		}
	}
}
